// base
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
// less
import './index.less'
import If from '../if'
import scaleImageSrc from '../../../util/pagemethods/scaleImageSrc'

class CompanyList extends Component {
  static defaultProps = {
    detail: {}
  }
  componentWillMount () {
    // onLoad
  }

  componentDidMount () {
    // onready
  }

  componentWillUnmount () {
    // onUnload
  }

  componentWillReceiveProps (nextprops) {}

  delay (time = 0) {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve()
      }, time)
    })
  }

  onTap = () => {
    this.props.onTap()
  }

  render () {
    const { detail, showIcon } = this.props
    return (
      <View className="CompanyList_id82713" onClick={this.onTap}>
        <Image className="image-left" src={scaleImageSrc(detail.companyLogo)} />
        <View className="right-box-in">
          <View className="cp-name">
            {showIcon ? '（当前公司）' : ''}
            {detail.companyName}
          </View>
          <View className="desc">{detail.showDetail}</View>
        </View>
        <If visible={showIcon}>
          <View className="abs-icon-part">
            <Image
              className="abs-icon-part"
              lazy-load
              src="https://imagesize.hrwork.com/sp/files/c515b6bc-713f-4174-967f-12d02f054185.png"
            />
          </View>
        </If>
      </View>
    )
  }
}

export default CompanyList
